Web からファイルを読み込むには、最初に HttpClient などの非同期リクエストオブジェクトを使用して、アプリケーションにファイルをダウンロードする必要があります。次に、結果のストリームを LoadDocument メソッドまたは LoadDocumentAsync メソッドに渡します。次のコード例では、HTTP リクエストを使用しています。
C# |
コードのコピー
|
---|---|
private async void LoadDocument() { // Web からファイルを読み込みます HttpClient client = new HttpClient(); string url = “http://cdn.componentone.com/files/win8/Win8_UXG_RTM.pdf”; try { var stream = await client.GetStreamAsync(new Uri(url, UriKind.Absolute)); pdfViewer.LoadDocument(stream); } catch { var dialog = new MessageDialog("There was an error attempting to download the document."); dialog.ShowAsync(); } } |